<?php

/**
 * @author Sanches
 * @copyright 2008
 */

include '../config.php';

if (isset($_REQUEST['captcha']))
{
$_REQUEST['jpg']=basename($_REQUEST['captcha']);
$file = $PARTICULA['DIR']['tpl']."captcha/captcha_".$_REQUEST['captcha'];
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
fclose($fh);
header("Content-type: image/jpeg");

print $contents;		
}
else
if (isset($_REQUEST['css']))
{
$_REQUEST['css']=basename($_REQUEST['css']);
$file = $PARTICULA['DIR']['admin'].$_REQUEST['css'];
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+604800)); 
header("Content-Type: text/css");
print $contents;		
}
else
if (isset($_REQUEST['js']))
{
$_REQUEST['css']=basename($_REQUEST['js']);
$file = $PARTICULA['DIR']['admin'].$_REQUEST['js'];
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+1209600)); 
header("Content-Type: text/javascript");
print $contents;		
}
else
if (isset($_REQUEST['jpg']))
{
$_REQUEST['jpg']=basename($_REQUEST['jpg']);
$file = $PARTICULA['DIR']['admin']."tpl/".$_REQUEST['jpg'];
if (file_exists($file))
{
$fh = fopen($file, 'r');
}
else
{
$file = $PARTICULA['DIR']['img'].$_REQUEST['jpg'];	
$fh = fopen($file, 'r');
}
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+604800)); 
header("Content-type: image/jpeg");
print $contents;		
}
else
if (isset($_REQUEST['png']))
{
$_REQUEST['png']=basename($_REQUEST['png']);
$file = $PARTICULA['DIR']['admin']."tpl/".$_REQUEST['png'];
if (file_exists($file))
{
$fh = fopen($file, 'r');
}
else
{
$file = $PARTICULA['DIR']['img'].$_REQUEST['png'];	
$fh = fopen($file, 'r');
}
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+604800)); 
header("Content-type: image/png");
print $contents;		
}
else
if (isset($_REQUEST['gif']))
{
$_REQUEST['gif']=basename($_REQUEST['gif']);
$file = $PARTICULA['DIR']['admin']."tpl/".$_REQUEST['gif'];
if (file_exists($file))
{
$fh = fopen($file, 'r');
}
else
{
$file = $PARTICULA['DIR']['img'].$_REQUEST['gif'];	
$fh = fopen($file, 'r');
}
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+604800)); 
header("Content-type: image/gif");
print $contents;		
}
else
if (isset($_REQUEST['ico']))
{
$_REQUEST['ico']=basename($_REQUEST['ico']);
$file = $PARTICULA['DIR']['admin']."tpl/".$_REQUEST['ico'];
if (file_exists($file))
{
$fh = fopen($file, 'r');
}
else
{
$file = $PARTICULA['DIR']['img'].$_REQUEST['ico'];	
$fh = fopen($file, 'r');
}
$contents = fread($fh, filesize($file));
fclose($fh);
header("Expires: ".date("r",time()+604800)); 
header("Content-type: image/x-icon");
print $contents;		
}
?>